<?php
/**
 * Created by PhpStorm.
 * User: huang
 * Date: 2018/9/18 0018
 * Time: 17:10
 */

namespace app\store\controller;

use app\store\model\PromotionFullMail as PromotionFullMailModel;
use app\store\model\PromotionFullMail;
use app\store\model\Region;

/**
 * 营销
 * Class Promotion
 * @package app\store\controller
 */
class Promotion extends Controller
{
    /**
     * 满额包邮
     * @return array|mixed
     */
    public function full()
    {
        $info = PromotionFullMailModel::detail();
        $info['no_mail_city_name'] = htmlspecialchars_decode($info['no_mail_city_name']);
        $regionData = json_encode(Region::getCacheTree());
        if ($this->request->isAjax()) {
            $model = new PromotionFullMail();
            if ($model->edit($this->postData('mail'))) {
                return $this->renderSuccess('更新成功');
            } else {
                return $this->renderError('更新失败');
            }
        }
        return $this->fetch('full', compact('info', 'regionData'));
    }
}